﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.database;
using ERP_RORZE_DLL.Product.DAO;

namespace ERP_RORZE_PRODUCT.Product.BasicList
{
    public partial class frm_WorkEdit : DevExpress.XtraEditors.XtraForm
    {
        ClsBasicListDAO clsBasiclistDAO = new ClsBasicListDAO();
        Work b = new Work();
        public event EventHandler Reload;
        public string WorkID;
        public string WorkName;
        public string DirectWork;
        public string MachWork;
        public string MachInDWork;
        public string MachineRun;

        public frm_WorkEdit()
        {
            InitializeComponent();
        }

        private void frm_WorkEdit_Load(object sender, EventArgs e)
        {
            txtWorkID.Text = WorkID;
            txtWorkName.Text = WorkName;
            checkDirectWork.Checked = bool.Parse(DirectWork);
            checkMachInDWork.Checked = bool.Parse(MachInDWork);
            checkMachineRun.Checked = bool.Parse(MachineRun);
            checkMachWork.Checked = bool.Parse(MachWork);
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtWorkName.Text == "")
            {
                MessageBox.Show("chưa nhập WorkName");
            }
            else
            {
                b.WorkID = txtWorkID.Text;
                b.WorkName = txtWorkName.Text;
                b.DirectWork = checkDirectWork.Checked;
                b.MachInDWork = checkMachInDWork.Checked;
                b.MachineRun = checkMachineRun.Checked;
                b.MachWork = checkMachWork.Checked;
                clsBasiclistDAO.UpdateWork(b);
                Reload(sender, e);
            }
        }
    }
}